using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class SO_CONTRACTMap : EntityTypeConfiguration<SO_CONTRACT>
    {
        public SO_CONTRACTMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ID, t.NAME, t.START_DATE, t.END_DATE, t.CURRENCY });

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.NAME)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.CONTRACT__)
                .HasMaxLength(10);

            this.Property(t => t.Guarantor_Id)
                .HasMaxLength(6);

            this.Property(t => t.GUARANTOR)
                .HasMaxLength(60);

            this.Property(t => t.CURRENCY)
                .IsRequired()
                .HasMaxLength(5);

            // Table & Column Mappings
            this.ToTable("SO_CONTRACT");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.NAME).HasColumnName("NAME");
            this.Property(t => t.CONTRACT__).HasColumnName("CONTRACT_#");
            this.Property(t => t.Guarantor_Id).HasColumnName("Guarantor_Id");
            this.Property(t => t.GUARANTOR).HasColumnName("GUARANTOR");
            this.Property(t => t.START_DATE).HasColumnName("START_DATE");
            this.Property(t => t.END_DATE).HasColumnName("END_DATE");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.note).HasColumnName("note");
        }
    }
}
